package com.poetize.plus.entity.dto;

import com.poetize.plus.entity.po.BackgroundImage;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;

/**
 * @author zuosy
 * @created 2024/4/10 13:18
 */
public record BackgroundImageDTO(
        @Schema(description = "文件名称")
        @NotBlank(message = "文件名称不能为空")
        String filename,

        @Schema(description = "文件路径")
        @NotBlank(message = "文件路径不能为空")
        String path,

        @Schema(description = "文件类型")
        @NotBlank(message = "文件类型不能为空")
        String mimeType
) {
    /**
     * DTO转实体类
     *
     * @param backgroundImageDTO
     * @return
     */
    public static BackgroundImage convertDTO(BackgroundImageDTO backgroundImageDTO) {
        return new BackgroundImage(null, backgroundImageDTO.path, backgroundImageDTO.filename, backgroundImageDTO.mimeType);
    }
}
